package ru.amse.ilyin.diagram.impl;

import java.awt.Point;

import ru.amse.ilyin.analyzer.Entity;
import ru.amse.ilyin.diagram.Renderer;

/**
 * Graphical representation of a class (interface).
 *
 * @author Alexander Ilyin
 */
public class ClassElement extends AbstractElement {
	private static final int RADIUS = 10;
	
	private final Entity entity;
	
	/**
	 * Creates new element of a class diagram.
	 * 
	 * @param entity class or interface
	 */
	public ClassElement(Entity entity) {
		this.entity = entity;
	}
	
	@Override
	public String getName() {
		return entity.getName();
	}

	@Override
	public Point getCenter() {
		return new Point(getLocation().x + RADIUS, getLocation().y + RADIUS);
	}

	public void draw(Renderer renderer) {
		renderer.drawOval(getLocation().x, getLocation().y, 2 * RADIUS, 2 * RADIUS);
		renderer.drawString(getName(), getLocation().x, getLocation().y);
	}
}
